home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 4993 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.2 KB

  1. Path: news1.h1.usa.pipeline.com!usenet
  2. From: grantp@usa.pipeline.com(Pete)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: "new" creams data structure -- why?
  5. Date: 2 Feb 1996 00:14:42 GMT
  6. Organization: Kalevi, Inc.
  7. Message-ID: <4erl1i$oas@news1.usa.pipeline.com>
  8. NNTP-Posting-Host: pipe8.h1.usa.pipeline.com
  9. X-PipeUser: grantp
  10. X-PipeHub: usa.pipeline.com
  11. X-PipeGCOS: (Pete)
  12. X-Newsreader: Pipeline USA v3.3.0
  13.  
  14. On Feb 01, 1996 23:08:16 in article <"new" creams data structure -- why?>,
  15. '<73067.3334@compuserve.com>' wrote: 
  16.  
  17.  
  18. >dear experts:  why would the following line alloc memory where there is 
  19. >insufficient space for it?  when i memcpy to clear the string, it wipes
  20. out 
  21. >a data structure i needed.  the line is 
  22. >char* somestring = new char [300]; 
  23. >when it's my fault i can deal with it, but how do i prevent this?  or is
  24. it 
  25. >a scoping problem or something? 
  26. >many thanks for any ideas. 
  27.  
  28. If operator new fails -- assuming it's the default 
  29. global one -- it returns 0.  If you don't test for it, then it's 
  30. your fault.  But I suspect the problem is elsewhere. 
  31.  
  32. Post a sample program that demonstrates the problem you're 
  33. experiencing.   
  34.  
  35. -- 
  36. Pete Grant 
  37. Kalevi, Inc. 
  38. Object Oriented Software Development
  39.